#!/usr/bin/perl -w
package DicerCant::World::Tile;
# DicerCant::World::Tile.pm:
#   This package contains methods for working with DicerCant .prp and .tls
#   files.  It manages tile sets, so to speak.
#
# Copyright (C) 2009  Justin Lee  < kool.name at gmail.com >
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
# USA.


use strict;
use warnings;


# Globals:



# Methods:

sub new {
	shift->spawn(@_)
}

sub build {
	shift->spawn(@_)
}

sub spawn {
	my ($package, $file) = @_;

	my $link = do $file;

	$@ and do {
		warn("$@: $file"), return (undef);
	};
	ref($link) eq 'HASH' or do {
		warn("$file did not return a hash reference"), return (undef);
	};

	return (bless ($link, $package));
}

sub get {
	my ($link, $key) = @_;

	ref($link) eq __PACKAGE__ or do {
		warn('This package is not nestable'), return (undef);
	};
	exists($link->{$key}) or do {
		return (undef);
	};

	return (bless ($link->{$key}, __PACKAGE__));
}

sub link {
	my ($tile) = @_;

	ref($tile) eq __PACKAGE__ or do {
		warn('This package is not nestable'), return (undef);
	};
}


__PACKAGE__;

